package com.brspace.qualitycontrol.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.brspace.qualitycontrol.entity.Process;
import com.brspace.qualitycontrol.mapper.ProcessMapper;
import com.brspace.qualitycontrol.service.ProcessService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.brspace.qualitycontrol.utils.EmptyUtil;
import com.brspace.qualitycontrol.utils.ServiceException;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2021-04-02
 */
@Service
public class ProcessServiceImpl extends ServiceImpl<ProcessMapper, Process> implements ProcessService {

    /**
     *@Description 保存流程
     *@Params [process]
     *@author Hugo
     *@date 2021-03-25 10:11
     *@return
     **/
    @Override
    public void saveProcess(Process process) {
        if (process.getFlowName().equals("")){
            throw new ServiceException("所输入流程名称不能为空");
        }
        if (baseMapper.selectList(new QueryWrapper<Process>().eq("flow_name",process.getFlowName())).size() > 0){
            throw new ServiceException("已有流程");
        }
        baseMapper.insert(process);
    }

}
